package com.bee.剑指offer;

import java.util.ArrayList;
import java.util.List;

public class 二叉搜索树的第k个节点 {
    
    private List<Integer> in = new ArrayList<>();

    public int KthNode (TreeNode proot, int k) {
        inRound(proot);
        if (k <= 0 || in.size() <= 0 || k > in.size()) {
            return -1;
        }
        return in.get(k - 1);
    }

    public void inRound(TreeNode root) {
        if(root == null) {
            return;
        }
        inRound(root.left);
        in.add(root.val);
        inRound(root.right);
    }

    public static void main(String[] args) {

    }
}
